package com.xjlsoft.weather.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * �����ļ���ȡ����
 * @author 1919
 *
 */
public class ConfigReader {

	private static final Logger logger = LoggerFactory.getLogger(ConfigReader.class);

	public static final String RQ_ECNAME=getProperties("application.properties").getProperty("rq_ecName");
	public static final String RQ_APID=getProperties("application.properties").getProperty("rq_apId");
	public static final String RQ_SECREKEY=getProperties("application.properties").getProperty("rq_secretKey");
	public static final String RQ_SIGN=getProperties("application.properties").getProperty("rq_sign");
	public static final String RQ_ADDSERIAL=getProperties("application.properties").getProperty("rq_addSerial");
    public static final String RQ_SEND_URL=getProperties("application.properties").getProperty("rq_sendUrl");
    
    
    
    public static final String RL_ECNAME=getProperties("application.properties").getProperty("rl_ecName");
	public static final String RL_APID=getProperties("application.properties").getProperty("rl_apId");
	public static final String RL_SECREKEY=getProperties("application.properties").getProperty("rl_secretKey");
	public static final String RL_SIGN=getProperties("application.properties").getProperty("rl_sign");
	public static final String RL_ADDSERIAL=getProperties("application.properties").getProperty("rl_addSerial");
	
    public static final String RL_SEND_URL=getProperties("application.properties").getProperty("rl_sendUrl");
    
    public static final String 	RQ_ACCOUNT=getProperties("application.properties").getProperty("rq_account");
    public static final String RQ_PWD=getProperties("application.properties").getProperty("rq_pwd");
    public static final String 	RQ_ACCEPT=getProperties("application.properties").getProperty("rq_Accept");
    public static final String RQ_VERSION=getProperties("application.properties").getProperty("rq_version");
    
    
    
    //΢���ƶ���Ϣ��ַ
    public static final String RQ_URL=getProperties("application.properties").getProperty("rq_url");
    public static final String RL_URL=getProperties("application.properties").getProperty("rl_url");
    //΢��ģ���ַ����
    public static final String RQ_TEMPLATEURL=getProperties("application.properties").getProperty("rq_templateUrl");
	
    //微信模板编码
    public static final String RQ_TEMPLATECODE1=getProperties("application.properties").getProperty("rq_wx1");
    public static final String RQ_TEMPLATECODE2=getProperties("application.properties").getProperty("rq_wx2");
    public static final String RQ_TEMPLATECODE3=getProperties("application.properties").getProperty("rq_wx3");
    //账单催缴  提醒
    public static final String RQ_TEMPLATECODE4=getProperties("application.properties").getProperty("rq_wx4");
    public static final String RQ_TEMPLATECODE5=getProperties("application.properties").getProperty("rq_wx5");
    public static final String RQ_TEMPLATECODE6=getProperties("application.properties").getProperty("rq_wx6");
    public static final String RQ_TEMPLATECODE7=getProperties("application.properties").getProperty("rq_wx7");
    public static final String RQ_TEMPLATECODE8=getProperties("application.properties").getProperty("rq_wx8");
    public static final String RQ_TEMPLATECODE9=getProperties("application.properties").getProperty("rq_wx9");
    
    
    public static final String isSend_smsBatchJob_TiXing=getProperties("application.properties").getProperty("isSend_smsBatchJob_TiXing");

    public static final String smsBatchJobSendUserNoStr=getProperties("application.properties").getProperty("smsBatchJobSendUserNoStr");
    
    public static final String sendAdminUserNoStr=getProperties("application.properties").getProperty("sendAdminUserNoStr");
   
	private static ConfigReader configreader = null;

	private ConfigReader() {

	}

	public static ConfigReader initConfigreader() {
		if (configreader == null) {
			configreader = new ConfigReader();
		}
		return configreader;
	}

	private Properties initProperties(String path) {
		InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
		Properties p = new Properties();
		try {
			//p.load(inputStream);
			p.load(new InputStreamReader(inputStream, "UTF-8"));
		} 
		catch (IOException e) {
			logger.error("��ȡ�����ļ�����������ϢΪ��" + e.getMessage());
		} 
		finally {
			if (inputStream != null) {
				try {
					inputStream.close();
				} 
				catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return p;
	}

	public static Properties getProperties(String path) {
		ConfigReader reader = new ConfigReader();
		return reader.initProperties(path);
	}
}
